Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled Topic Owners to properly delete posts in their topic #20

Merged
merged 7 commits into from
Feb 27, 2025

Conversation

jonassoh
Copy link
Contributor

@jonassoh jonassoh commented Feb 20, 2025

Context
Topic Owners could see the delete option on posts under their topic/thread but upon clicking the delete button, they would not have the permissions to delete and so the action would fail.

Description
Now, when a topic owner selects a post, the post will be marked as deleted and have all the attributes of a deleted post.

File Changes
src/socket.io/posts/tools.js
Updated the display permissions to display admin or moderator post options only if the user is an admin or moderator and not just if they have edit or delete permissions

src/privileges/posts.js
Under the privPosts.canDelete function, added a variable to check if the user is a topic owner and modified the flag to also be true if the user is the topic owner.

test/posts.js
Added set up and test case to see a topic Owner has the permission/privilege to delete posts under their topic.

Testing
Verified changes on the front end. Topic owner was able to successfully delete posts and did not have admin permissions.
Verified back end changes worked properly through test cases in test/posts.js

… can delete posts in their topic. modified socket.io/posts/tools.js to not display admin positions along with topic owner position
@RyanChernoff RyanChernoff self-requested a review February 21, 2025 18:51
@RyanChernoff
Copy link
Contributor

Your PR looks good but your code appears to be failing some of the lint tests. I would recommend making the changes suggested by the linter but otherwise looks good.

@coveralls
Copy link

coveralls commented Feb 21, 2025

Pull Request Test Coverage Report for Build 13557533598

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 82.686%

Files with Coverage Reduction New Missed Lines %
src/posts/edit.js 4 94.74%
Totals Coverage Status
Change from base Build 13271607482: 0.01%
Covered Lines: 22345
Relevant Lines: 25605

💛 - Coveralls

Copy link
Contributor

@RyanChernoff RyanChernoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now that the lint errors were fixed

@rmurugan58 rmurugan58 self-requested a review February 27, 2025 02:12
Copy link
Contributor

@rmurugan58 rmurugan58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good. The only thing I would check is the merge conflict still present in nodebb-theme-harmony/templates/topic.tpl. Besides this, the code looks good, and all lint tests are passing, so it looks ready to go.

Copy link
Contributor

@rmurugan58 rmurugan58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the merge conflicts are resolved, everything looks good!

@RyanChernoff RyanChernoff merged commit d85381e into main Feb 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants